
package br.com.easyrhour3x.main;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JPopupMenu;

class PopupListener extends MouseAdapter
{

   private JPopupMenu popup;

   PopupListener(JPopupMenu popupMenu)
   {
      popup = popupMenu;
   }

   public void mousePressed(MouseEvent e)
   {
      maybeShowPopup(e);
   }

   public void mouseReleased(MouseEvent e)
   {
      maybeShowPopup(e);
   }

   private void maybeShowPopup(MouseEvent e)
   {
      if (e.isPopupTrigger())
      {
         popup.show(e.getComponent(),
            e.getX(), e.getY());
      }
   }
}
